// 项目部署基础

const BASE_URL = process.env.NODE_ENV === "production" ? "./" : "/IOTPad";
let Timestamp = new Date().getTime();
let random = Math.floor(Math.random() * (1000000 - 1) + 1000000);
module.exports = {
  pages: {
    Index: {
      entry: "src/pages/Index/main.js",
      template: "public/Index.html",
      filename: "Index.html",
    },
  },
  // baseUrl: BASE_URL,
  // 如果你不需要使用eslint，把lintOnSave设为false即可
  lintOnSave: false,
  // 打包 文件名 路径
  outputDir: "IOTPad",
  publicPath: BASE_URL,
  assetsDir: "static",
  //configureWebpack 这部分打包文件添加时间戳，防止缓存不更新
  configureWebpack: {
    output: {
      // 输出重构  打包编译后的 文件名称  【随机数.时间戳】
      filename: `[name]-${random}-${Timestamp}.js`,
      chunkFilename: `[name]-${random}-${Timestamp}.js`,
    },
  },
  // 设为false打包时不生成.map文件
  productionSourceMap: false,

  devServer: {
    port: 8090, // 更改端口号
    proxy: {
      "/Api": {
        target: "http://119.3.248.208:7002",
        //target: "http://192.168.1.195:7002",
        changeOrigin: true,
        logLevel: "debug",
        pathRewrite: {
          "^/Api": "",
        },
      },
      "/smartiot": {
        target: "http://119.3.248.208:8080",
        //target: "http://192.168.1.195:8080",
        changeOrigin: true,
        logLevel: "debug",
        pathRewrite: {
          "^/smartiot": "",
        },
      },
    },
    headers: {
      "Access-Control-Allow-Origin": "*",
    },
  },
};
